/******************************************************************************
 *                       B O M B E R M A N  2 0 1 2
 * 
 * File Name: Barrier.java
 * 
 * COP 4331 Summer 2012 Project
 * 
 * Authors: Trevor Mancuso, Chris Chiarella, Zach Hoyler, Daniel Martin
 * 
 * 
 * Description: This class generates the barriers for the level.
 * 
 ******************************************************************************/
package bomberman;
import java.awt.Toolkit;
import java.util.*;

public class Barrier extends Entity 
{
    public boolean isDestructable;
    public boolean hasPowerup = false;
 
    //initilize the barrier for level generating
    Barrier()
    {
        //make a random number between 0 and 99
        Random rand = new Random();
        int randomNum = rand.nextInt(100);
        if(randomNum < 25) //if the number is less than 25 then make the barrier indestructable
            isDestructable = false;
        else //otherwise it is destructable and give it a 15% chance of having a powerup
        {
            isDestructable = true;
            if(rand.nextInt(100) < 15)
                hasPowerup = true;
        }
        
        setupSprite(); //set the sprite for it
    }
    
    //initilization for sudden death
    Barrier(boolean isDestructable)
    {
        //create an indestructable barrier
        this.isDestructable = isDestructable;
        setupSprite();
    }
    
    //set the sprites for the barriers based on destructable or indestructable
    private void setupSprite()
    {
        if (isDestructable)
            setSprite(Bomberman.Sprites.BARRIER.getSprite());
        else
            setSprite(Bomberman.Sprites.BARRIER_IND.getSprite());
    }
    
    //return whether or not the barrier is destructable
    public boolean isDestructable()
    {
        return isDestructable;
    }
}
